<?php
/*
 * Created on 18.11.2007
 *
 * filename: model_setup.php
 */

//define ('GET_ALL','SELECT * FROM `setup`');
//define ('SET_HEADER','update setup set header_text = ?');
//define ('SET_FOOTER','update setup set footer_text = ?');
//define ('SAVE_ALL_SETUPS','');

define ('MODEL_SITE_FIND_ALL',	'SELECT * FROM `setup`');
define ('MODEL_SITE_SAVE_ALL', 	'UPDATE `setup` SET `header_text` = ?, `footer_text` = ?, `add_condition_visibility` = ?,`add_condition_access` = ?, `title` = ?, `info_block` = ?  ');

define ('MODEL_SITE_SAVE_INDEX','UPDATE `setup` SET `image` = ?, `text` = ?');

class Model_Site extends Models_Base  {
	
	public $header;
	public $footer; 
	public $title;
	public $image;
	public $slogan;
	
	public $create = array();
	
	function __construct() {
		parent::__construct();
		
		$site = $this->findAll();
	
		$this->header 		= $site->header_text;
		$this->footer 		= $site->footer_text;
		$this->title  		= $site->title;
		$this->image		= $site->image;
		$this->slogan		= $site->text;
		$this->info_block	= $site->info_block;
		
		$this->create[visibility] 	= $site->add_condition_visibility;
		$this->create[access] 		= $site->add_condition_access;
	}
	
	private function findAll() {
		return $this->getRow(MODEL_SITE_FIND_ALL,array());
	}
	
/*	function getAll () {
		$sth = $this->dbh->prepare(GET_ALL);
		$sth->execute();
		
		return $sth->fetchObject();
	}
	
	function setHeaderText($text) {
		$sth = $this->dbh->prepare(SET_HEADER);
		$sth->execute(array($text));
	}

	function setFooterText($text) {
		$sth = $this->dbh->prepare(SET_FOOTER);
		$sth->execute(array($text));		
	}*/
	
	function saveAll($args) {
		$sth = $this->dbh->prepare(MODEL_SITE_SAVE_ALL);
		$sth->execute($args);
	}	
	
	function saveIndex($args) {
		$this->execute(MODEL_SITE_SAVE_INDEX,array($args['image'],strip_tags($args['slogan_text'], '<br>')));	
	}
	
 }
 
?>
